import { View } from "../../../mvc/core/View";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { ToolTipInfo } from "../../model/ToolTipInfo";
import { ChangeHeadIconConfig } from "../../resource/ChangeHeadIconConfig";
import { Cache } from "../../cache/Cache";
import { EquipmentUtil } from "../common/util/EquipmentUtil";
import { NormalTooltip } from "../common/tooltip/NormalTooltip";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
//class ChangeHeadAttributeTips
    
    export  class ChangeHeadAttributeTips extends View
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._loadedBtn = ObjCreate.createGLoadedButton(ResFileConst.ChangeHeadIconAttBtn, 0, 0, 29, 31, this);
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._tileBmpData = GlobalClass.getBitmapData(ImagesConst.ChangeHeadAttTotal);
            this._loadedBtn.toolTipData = this.getToolTip(this._tileBmpData);
            return;
        }

        /* internal  */getToolTip(arg1: Object /* flash.display.BitmapData */): ToolTipInfo
        {
            var loc4=null;
            var loc1=ChangeHeadIconConfig.instance.getAllHeadAddValue(Cache.instance.role.headIconArr);
            if (loc1 == null) 
            {
                return null;
            }
            var loc2=[];
            if (arg1) 
            {
                loc2.push(arg1);
            }
            var loc3=Cache.instance.role.entityInfo.career;
            var loc5=EquipmentUtil.getSelfCareerAttribute(loc3, loc1);
            var loc6="<font color=\'#00ff00\'>";
            var loc7=0;
            while (loc7 < loc5.length) 
            {
                loc4 = loc5[loc7];
                loc6 = loc6 + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + loc4.name + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+" + loc4.value + "\n";
                ++loc7;
            }
            loc6 = loc6 + "</font>";
            loc2.push(loc6);
            var loc8;
            return loc8 = new ToolTipInfo(NormalTooltip.ToolTipRenderType_Separate, loc2);
        }

        public updateAttribute(): void
        {
            if (this._tileBmpData != null) 
            {
                this._loadedBtn.toolTipData = this.getToolTip(this._tileBmpData);
            }
            else 
            {
                LoaderHelp.addResCallBack(ResFileConst.ChangeHeadIcon, this.onResLoaded);
            }
            return;
        }

        /* internal */ /* var */_loadedBtn: GLoadedButton;

        /* internal */ /* var */_tileBmpData: Object /* flash.display.BitmapData */;
    }
